// 分享链接
<template>
    <div>
        <GoBack></GoBack>
        <div class="ShareBox">
            <p class="adselfBox">推广链接</p>
            <div class="shareCont">
                <div class="inputBox flex flex-align-center">
                    <input type="text" :value="urltext" id='textCont'>
                    <div class="copyBtn flex flex-align-center flex-pack-center" @click="onCopyShareFun"><p>复制分享链接</p></div>
                </div>
                <div class="imgBox flex flex-align-center flex-pack-center" >
                    <img src="" alt="" id='qrcode'>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import QRCode from 'qrcode'
import GoBack from '../goback'
export default {
    components: {
        GoBack
    },
    data () {
        return {
            urlData:'', // 分享链接
            urltext:'' // 生成二维码链接
        }
    },
    mounted () {
       this.getNetText()
    },
    methods: {
        onCopyShareFun(){
            let text=document.getElementById("textCont");
            text.select(); // 选择对象
            document.execCommand("Copy");  //执行浏览器拷贝
        },
        qrcode(){
                let _self = this;
                 QRCode.toDataURL(this.urlData, {errorCorrectionLevel: 'H'}, function (err, url) {
                    document.getElementById('qrcode').src = url;
                })
            },
        getNetText(){
            let uid = this.$store.state.userInfo.id;
            this.https('common/getObtainWenExtend',{uid:uid})
            .then(data => {
                    this.urltext = data.qr_code_url;
                    this.urlData = data.qr_code_url;
                    this.qrcode(); 
            })
        }
    }
}
</script>
<style lang="less" scoped>
@import url(../../assets/css/usercenter/sharelink.less);
</style>


